CC=gcc
CFLAGS=-Wall -Wno-format -Wno-unused -Werror -pg
EXEC=zz
OBJS=encoder.o decoder.o test.o dict.o bit_reader.o

exec: $(OBJS) main.c defs.h
	$(CC) $(CFLAGS) -o $(EXEC) main.c $(OBJS)

decoder: decoder.o bit_reader.o
	$(CC) $(CFLAGS) -o decoder decoder.o bit_reader.o

decoder.o: decoder.c decoder.h
	$(CC) $(CFLAGS) -c decoder.c decoder.h

bit_reader.o: bit_reader.c bit_reader.h
	$(CC) $(CFLAGS) -c bit_reader.c bit_reader.h	

encoder.o: dict.o encoder.c encoder.h defs.h
	$(CC) $(CFLAGS) -c encoder.c

dict.o: dict.c dict.h defs.h
	$(CC) $(CFLAGS) -c dict.c
	
test.o: test.h test.c defs.h
	$(CC) $(CFLAGS) -c test.c

evaluate: exec
	 ./$(EXEC) -t
	 @cat log.txt

encode: exec
	@time ./$(EXEC) -e example.html encoded.txt
	@echo "Before compressed: "
	@du -hs example.html
	@echo "After compressed:" 
	@du -hs encoded.txt

decode: $(EXEC)
	./$(EXEC) -e -d encoded.txt decoded.txt

clean:
	rm -f zz *.o *.swp

all: exec
